<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" href="../../css/api.css" />
    <link rel="stylesheet" href="../../css/common.css" />
</head>

<body>
    <header class="yt-header">
        <h1 class="yt-header-title">预览文件</h1>
    </header>
    <section class="content">
        <button class="button block" onclick="preview()">预览图片</button>
        <div class="resault">

        </div>
    </section>
</body>
<script src="../../script/api.js"></script>
<script>
  var deviceReady = false
  var photoBrowser = null

  apiready = function() {
    deviceReady = true
    photoBrowser = api.require('photoBrowser')
  }

  function preview() {
    photoBrowser.open({
      images: [
        'https://img13.360buyimg.com/ling/jfs/t1/41/28/11924/322549/5bcc7032Eb10d58a1/4d2d427681ef624c.png',
        'https://img10.360buyimg.com/ling/jfs/t28504/206/891281106/27836/1fa0124a/5c00dc35N43121274.jpg'
      ],
      placeholderImg: 'widget://image/slider-pic.png',
      bgColor: '#000'
    }, function(ret, err) {
      if(ret) {
        if(ret.eventType == 'show') {
          api.openFrame({
            name: 'preview',
            url: './preview.html',
            rect: {
              x: 0,
              w: 'auto',
              h: '44',
            }
          })
        }
        api.bringFrameToFront({
            from: 'preview'
        })

        alert(JSON.stringify(ret))
      } else {
        alert(JSON.stringify(err))
      }
    })
  }

  function fnClose() {
    photoBrowser.close()
  }
</script>

</html>
